/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.igorov.efficientsoft.dataaccess.domain.hibernate;

import com.igorov.efficientsoft.dataaccess.base.hibernate.HibernateGenericDAO;
import com.igorov.efficientsoft.dataaccess.domain.PagoDAO;
import com.igorov.efficientsoft.dataaccess.model.TpagoVO;
import java.io.Serializable;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author igorov
 */
public class HibernatePagoDAO extends HibernateGenericDAO<TpagoVO, Integer> implements PagoDAO {

    public HibernatePagoDAO() {
        super(TpagoVO.class);
    }

    public List<TpagoVO> getAllByNumeroPedido(int numeroPedido) {
//        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TpagoVO.class);
//        detachedCriteria.
//                add(Restrictions.eq("tpedido.nNumPed", numeroPedido));
//         List<TpagoVO> tpagoVOs = listByCriteria(detachedCriteria);
//         return tpagoVOs;
        
        return this.getSession().
                createSQLQuery("SELECT tpago.nCodPag, tpago.dFecPag, tpago.lInicial," + 
                            "tpago.dDiaSig, tpago.nDiasRet, tpago.tpedido_nCodPed," +
                            "tpago.nCodUsu, tpago.dMonto FROM tpago,tpedido " +
                            "WHERE tpedido.nNumPed = " + numeroPedido +
                            " and tpedido.nCodPed = tpago.tpedido_nCodPed").
                addEntity(TpagoVO.class).list();
    }
    
}
